function Person() {
  this.think = function(callback) {
    // 异步函数
    setTimeout(function() {
      console.log('thinking~~~!');
      callback();
    }, 3000);
  };
  this.answer = function() {
    console.log('I am ansering other question!');
  };
}

var person = new Person();
person.think(function() {
  console.log('thinking 3 second,get the right answer!');
});
person.answer();

/**
 * callback
 */
function waitFive(name,func) {
  var pus = 0;
  var currentDate = new Date();
  // 阻塞
  while(pus<5000){
    var now = new Date();
    pus = now - currentDate;
  }
  func(name);
}

function echo(name) {
  console.log('my name is '+name);
}
waitFive('andy',echo);
console.log('程序执行结束！');